package net.lab1024.sa.base.config;

import cn.binarywang.wx.miniapp.api.WxMaOrderShippingService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaOrderShippingServiceImpl;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class WxMaConfiguration {

    @Autowired
    private WeixinProperties weixinProperties;


    @Bean
    public WxMaService wxMaService() {
        WxMaService maService = new WxMaServiceImpl();
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(weixinProperties.getAppid());
        config.setSecret(weixinProperties.getSecret());
        maService.setWxMaConfig(config);
        return maService;
    }

    @Bean
    public WxMaOrderShippingService wxMaOrderShippingService() {
        return new WxMaOrderShippingServiceImpl(wxMaService());
    }


}
